<%@ page language="java" pageEncoding="utf-8"%>

<!DOCTYPE html>
<html>
<head>
	<%@include file="../include_new.jsp"%>
</head>
<body id="z_body">
<div id="app">
	<form class="form-horizontal" id="form_1">
		<input name="rybh" v-model="one.rybh" type="hidden"/>
		
		<div class="form-group">
			<label class="col-xs-3">*警号</label>
			<div class="col-xs-7">
				<input class="form-control" name="ryjh" v-model="one.ryjh" validType="notEmpty">
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-xs-3">*姓名</label>
			<div class="col-xs-7">
				<input class="form-control" name="ryxm" v-model="one.ryxm" validType="notEmpty">
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-xs-3">*所属单位</label>
			<div class="col-xs-7">
				
				<shiro:hasRole name="admin">
					<input class="form-control" name="ssdwdm" v-model="one.ssdwdm" validType="" type="hidden">
					<input class="form-control" name="ssdwmc" v-model="one.ssdwmc" validType="notEmpty" data_tree="{type:'organ'}">
				</shiro:hasRole>
				<shiro:lacksRole name="admin">
					<input class="form-control" value="${loginUser.ssdwmc}" readonly="readonly">
				</shiro:lacksRole>
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-xs-3">电话</label>
			<div class="col-xs-7">
				<input class="form-control" name="dhhm" v-model="one.dhhm" validType="">
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-xs-3">性别</label>
			<div class="col-xs-7">
				<input class="form-control" name="ryxb" v-model="one.ryxb" validType="" type="hidden">
				<input class="form-control" name="xbms" v-model="one.xbms" validType="" data_tree="{type:'sex'}">
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-xs-3">职务</label>
			<div class="col-xs-7">
				<input class="form-control" name="ryzw" v-model="one.ryzw" validType="" type="hidden">
				<input class="form-control" name="zwms" v-model="one.zwms" validType="" data_tree="{type:'ryzw'}">
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-xs-3"></label>
			<div class="col-xs-7">
				<a class="btn btn-primary" onclick="save()">保存</a> &nbsp;
				<a class="btn btn-default" href="javascript:;" onclick="parent.closeModal()">取消</a>
			</div>
		</div>
		
	</form>
</div>
	
<script type="text/javascript">
	var act = "${act}", id = "${id}";
	
	var vm = new Vue({
		el: "#app",
		data: {
			act: act,
			one: {}
		}
	});
	
	if(act == "update") {
		tool.query("../ry/load4Update", {id: id}, function(data) {//提交
			vm.one = data;
		});
	}

	//保存
	function save() {
		if(validateForm("form_1")) {//表单验证
			tool.save("../ry/"+act, $("#form_1").serialize(), function(data) {//提交
				parent.getPage();
				setTimeout(function(){
					parent.closeModal();
				}, 800);
			});
		}
	}
	
</script>
<style type="text/css">
	#z_body{min-height:500px;}
</style>
</body>
</html>